<template>
	<view class="popup">
		<view class="popup-center" v-if="trainging.withInTimeFlag === false">
			<view>{{trainging.backMsg}}</view>
		</view>
		<view class="popup-left" v-else>
			<view>培训名称：{{trainging.trainName}}</view>
			<view>培训地点：{{trainging.trainAddress}}</view>
			<view>培训教师：{{trainging.teacherNames}}</view>
		</view>
		<view class="popup-footer">
			<view class="popup-footer-2" @click="handleConfirm">{{trainging.withInTimeFlag === false?'确认':'签到'}}
			</view>
		</view>
	</view>
</template>

<script>
	import {
		signDetail,
		signTrain
	} from '@/api/educational-training/trainingTasks'
	export default {
		data() {
			return {
				id: '',
				trainging: {}
			}
		},
		onLoad({
			id
		}) {
			this.id = id
		},
		created() {
			this.getDetail()
		},
		methods: {
			async getDetail() {
				const res = await signDetail(this.id)
				this.trainging = res.data
			},
			async handleConfirm() {
				if (this.trainging.withInTimeFlag === false) {
					uni.navigateBack()
				} else {
					await signTrain(this.id)
					this.$modal.msgSuccess('签到成功');
					const time = setInterval(() => {
						clearInterval(time)
						uni.navigateBack()
					}, 2000);

				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.popup {
		background: #fff;
		width: 650rpx;
		position: relative;
		background: #ffffff;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		opacity: 1;
		font-family: PingFang SC-Regular, PingFang SC;
		left: 50rpx;
		top: 450rpx;
	}

	.popup-center {
		padding-top: 140rpx;
		text-align: center;
		font-size: 120rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
		padding-bottom: 180rpx;
	}

	.popup-left {
		margin-left: 180rpx;
		padding-top: 140rpx;
		text-align: left;
		font-size: 80rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
		padding-bottom: 180rpx;
	}

	.popup-img {
		width: 182rpx;
		height: 182rpx;
		position: absolute;
		z-index: 1;
		left: 50%;
		transform: translateX(-50%);
		top: -54rpx;
	}

	.popup-footer {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 34rpx;
		padding: 0 50rpx;
		color: #454a5e;
		box-sizing: border-box;
		position: absolute;
		z-index: 1;
		left: 0;
		bottom: 40rpx;

		.popup-footer-1,
		.popup-footer-2,
		.popup-footer-3,
		.popup-footer-4 {
			width: 246rpx;
			height: 88rpx;
			text-align: center;
			border-radius: 44rpx 44rpx 44rpx 44rpx;
			line-height: 88rpx;
		}

		.popup-footer-1 {
			border: 1rpx solid #454a5e;
			width: 244rpx;
			height: 86rpx;
			line-height: 86rpx;
		}

		.popup-footer-2 {
			background: #88b4c4;
			color: #ffffff;
		}

		.popup-footer-3 {
			background: #c87c32;
			color: #ffffff;
		}

		.popup-footer-4 {
			border: 1rpx solid #454a5e;
			width: 244rpx;
			height: 86rpx;
			line-height: 86rpx;
		}
	}
</style>